import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../manager/room_floating_view.dart';

/// 显示、隐藏房间悬浮窗
mixin RoomOverlayMixin {
  OverlayEntry? overlayEntry;

  void showOverlay() {
    if (overlayEntry != null) hideOverlay();

    overlayEntry = OverlayEntry(builder: (context) {
      return const RoomFloatingView();
    });

    var overlayState = Overlay.of(Get.context!);
    overlayState.insert(overlayEntry!);
  }

  void hideOverlay() {
    overlayEntry?.remove();
    overlayEntry = null;
  }
}
